package com.example.data.factory.common.Exception;

public enum CommonErrorCode {
    DB_ERROR("DB_ERROR", "数据库错误", 500),
    IO_ERROR("IO_ERROR", "IO异常", 500),
    NET_ERROR("NET_ERROR", "网络异常", 500),
    BUSINESS_ERROR("BUSINESS_ERROR", "业务异常", 400),
    TRANSACTION_ERROR("TRANSACTION_ERROR", "事务异常", 500),
    UNKNOWN_ERROR("UNKNOWN_ERROR", "未知异常", 500),
    INVALID_PARAM("INVALID_PARAM", "请求参数非法", 400),
    PARAM_FORMAT_ERROR("PARAM_FORMAT_ERROR", "参数格式错误", 400),
    REQUEST_REPEATED("REQUEST_REPEATED", "重复的请求", 400),
    TIMEOUT("TIMEOUT", "请求超时", 408),

    SERVER_ERROR("501", "服务器处理异常", 501),
    SUCCESS("200", "成功", 200),
    FAIL("FAIL", "失败", 500),
    LOGIN("777", "需要登录", 401),

    FIELD_REPEAT("FIELD_REPEAT", "字段重复", 409),
    DB_GET_DATA_ERROR("DB_GET_DATA_ERROR", "数据库获取数据错误", 500),
    STOP_FAIL("STOP_FAIL", "停用失败", 500);

    private final String code;
    private  final String message;
    private  final int httpStatus;

    CommonErrorCode(String code, String message, int httpStatus) {
        this.code = code;
        this.message = message;
        this.httpStatus = httpStatus;
    }

    public String getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public int getHttpStatus() {
        return this.httpStatus;
    }
}